package com.uzai.console.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 支付宝账单支付类型
 * @Auther: liuqi
 * @Date: 2021/8/19 11:22
 * @Description:
 */
public enum TensentCosErrorEnum {
    ActionAccelerateNotSupported(400, "ActionAccelerateNotSupported", "加速域名不支持该操作"),
    AttachmentFull(400, "AttachmentFull", "ACL 和 Policy 数量到达上限"),
    BadDigest(400, "BadDigest", "提供的 Content-MD5 值与服务端收到的请求体的 MD5 哈希值不一致"),
    BadRquest(400, "BadRquest", "参数错误"),
    BucketAccelerateNotEnabled(400, "BucketAccelerateNotEnabled", "该存储桶未启用加速域名"),
    BucketNameTooLong(400, "BucketNameTooLong", "存储桶名称过长"),
    BucketVersionNotOpen(400, "BucketVersionNotOpen", "存储桶未启用版本控制"),
    DNSRecordVerifyFailed(400, "DNSRecordVerifyFailed", "DNS 记录验证失败，请添加 CNAME 或 TXT 记录。DNS 记录可能需要最多10分钟生效"),
    EntitySizeNotMatch(400, "EntitySizeNotMatch", "请求体大小与 Content-Length 请求头不符"),
    EntityTooLarge(400, "EntityTooLarge", "上传的对象大小超过规定的最大值"),
    EntityTooSmall(400, "EntityTooSmall", "上传的对象大小不足规定的最小值"),
    ExpiredToken(400, "ExpiredToken", "临时密钥 Token 已过期"),
    ImageResolutionExceed(400,"ImageResolutionExceed","图片分辨率超出限制或动图帧数过多"),
    ImageTooLarge(400,"ImageTooLarge","图片超过限制大小"),
    IncompleteBody(400, "IncompleteBody", "请求体大小小于 Content-Length 请求头"),
    IncorrectNumberOfFilesInPostRequest(400, "IncorrectNumberOfFilesInPostRequest", "POST Object 请求每次只允许上传一个对象"),
    InvalidArgument(400, "InvalidArgument", "请求参数不合法，请确认是否允许携带该请求参数"),
    InvalidBucketName(400, "InvalidBucketName", "存储桶名称不合法"),
    InvalidCopySource(400, "InvalidCopySource", "复制对象源不合法"),
    InvalidDelimiter(400, "InvalidDelimiter", "分隔符（delimiter）参数不合法，分隔符只能为一个字符"),
    InvalidDigest(400, "InvalidDigest", "给定的 Content-MD5 值不合法"),
    InvalidImageFormat(400, "InvalidImageFormat", "图片格式不合法"),
    InvalidImageSource(400, "InvalidImageSource", "图片源不合法"),
    InvalidLocationConstraint(400, "InvalidLocationConstraint", "指定的 location 不合法"),
    InvalidObjectName(400, "InvalidObjectName", "对象名称不合法"),
    InvalidPart(400, "InvalidPart", "分块缺失"),
    InvalidPartOrder(400, "InvalidPartOrder", "分块的编号不连续"),
    InvalidPicOperations(400, "InvalidPicOperations", "Pic-Operations 请求头不合法"),
    InvalidPolicyDocument(400, "InvalidPolicyDocument", "POST Object 请求中的策略（Policy）不合法"),
    InvalidRegionName(400, "InvalidRegionName", "不合法的地域名"),
    InvalidRequest(400, "InvalidRequest", "请求不合法"),
    InvalidSHA1Digest(400, "InvalidSHA1Digest", "请求内容 SHA1 校验不合法"),
    InvalidTag(400, "InvalidTag", "存储桶标签不合法"),
    InvalidTargetBucketForLogging(400, "InvalidTargetBucketForLogging", "用于存放日志的目标存储桶不合法，目标存储桶必须与当前存储桶在同一个地域"),
    InvalidUploadStatus(400, "InvalidUploadStatus", "当启用版本控制时不能使用 JSON API 上传对象，请使用 XML API"),
    InvalidURI(400, "InvalidURI", "URI 不合法"),
    InventoryFull(400, "InventoryFull", "清单任务数量已达到限制。清单任务上限1000条"),
    JsonAPINotSupportOnMAZBucket(400, "JsonAPINotSupportOnMAZBucket", "JSON API 不支持操作多 AZ 存储桶，请使用 XML API"),
    KeyTooLong(400, "KeyTooLong", "对象键过长"),
    KmsException(400, "KmsException", "密钥管理服务异常"),
    KmsKeyDisabled(400, "KmsKeyDisabled", "提供的密钥已被禁用"),
    KmsKeyNotExist(400, "KmsKeyNotExist", "提供的密钥不存在"),
    ListPartUploadIdIsEmpty(400, "ListPartUploadIdIsEmpty", "UploadId 为空"),
    LoggingConfExists(400, "LoggingConfExists", "日志配置已存在"),
    LoggingPrefixInvalid(400, "LoggingPrefixInvalid", "日志前缀参数不合法"),
    MalformedPolicy(400, "MalformedPolicy", "策略格式不合法"),
    MalformedPOSTRequest(400, "MalformedPOSTRequest", "该 POST 请求的请求体内容不合法"),
    MalformedXML(400, "MalformedXML", "请求体的 XML 格式不符合 XML 语法"),
    MAZOperationNotSupportOnOAZBucket(400, "MAZOperationNotSupportOnOAZBucket", "单可用区（单 AZ）存储桶不支持多可用区（多 AZ）操作"),
    MissingRequestBodyError(400, "MissingRequestBodyError", "请求体缺失"),
    MultiAZFeatureNotSupport(400, "InvalidTag", "当前地域不支持多可用区"),
    MultiBucketNotSupport(400, "MultiBucketNotSupport", "跨地域复制只能设置一个目的存储桶"),
    NotifyRuleEventConflict(400, "NotifyRuleEventConflict", "通知规则 Event 冲突"),
    NotifyRulePrefixConflict(400, "NotifyRulePrefixConflict", "通知规则 Prefix 冲突"),
    NotifyRuleSuffixConflict(400, "NotifyRuleSuffixConflict", "通知规则 Suffix 冲突"),
    NotSupportedStorageClass(400, "NotSupportedStorageClass", "指定的 存储类型 不支持"),
    OAZOperationNotSupportOnMAZBucket(400, "OAZOperationNotSupportOnMAZBucket", "多可用区存储桶不支持单可用区操作"),
    PolicyFull(400, "PolicyFull", "ACL 和 Policy 数量到达上限"),
    PolicyVersionFull(400, "PolicyVersionFull", "Policy 版本数量到达上限"),
    RequestTimeout(400, "RequestTimeout", "请求超时"),
    SsecDecryptHeaderInvalid(400, "SsecDecryptHeaderInvalid", "源文件使用 SSE-C 加密，需要在请求头中提供相同的密钥"),
    SSEContentNotSupported(400, "SSEContentNotSupported", "加密方式不支持"),
    SSEHeaderNotAllowed(400, "SSEHeaderNotAllowed", "该操作不支持指定的服务端加密头部"),
    TargetBucketNameInvalid(400, "TargetBucketNameInvalid", "目标存储桶名称不合法"),
    TooManyBuckets(400, "TooManyBuckets", "存储桶数目达到上限200"),
    UnexpectedContent(400, "UnexpectedContent", "请求不支持相关内容"),
    UserCnameInvalid(400, "UserCnameInvalid", "用户指定的 CNAME 不存在或不合法"),
    UserNetworkTooSlow(400, "UserNetworkTooSlow", "用户的网络速度过慢"),
    VerifyAlgorithmNotSupported(400, "VerifyAlgorithmNotSupported", "校验算法不支持"),
    WebsiteURLInvalid(400, "WebsiteURLInvalid", "自定义域名 URL 不合法"),
    XMLSizeLimit(400, "XMLSizeLimit", "XML 长度超过限制"),
    PaymentRequired(402, "PaymentRequired", "超出费用配额限制"),
    AccessDenied(403, "AccessDenied", "签名或者权限不正确，拒绝访问"),
    AccessForbidden(403, "AccessForbidden", "跨域资源共享（CORS）请求被拒绝，请检查请求方法或请求头部中的 Origin、Access-Control-Request-Method、Access-Control-Request-Headers 是否在配置的 CORS 白名单中"),
    InvalidAccessKeyId(403, "InvalidAccessKeyId", "SecretID 不存在"),
    InvalidObjectState(403, "InvalidObjectState", "对象存储类型与操作请求冲突"),
    NoProcessAuthority(403, "NoProcessAuthority", "没有处理图片的权限"),
    RequestTimeTooSkewed(403, "RequestTimeTooSkewed", "本地时间与服务器时间相差过大，超过15分钟"),
    RequestHasExpired(403, "Request has expired", "发起请求的时间超过了签名的有效时间，或者本地系统时间和所在时区的时间不一致"),
    SignatureDoesNotMatch(403, "SignatureDoesNotMatch", "客户端计算的签名与 COS 服务端计算的签名不一致"),
    UserNotSourceBucketOwner(403, "UserNotSourceBucketOwner", "当前用户不是源存储桶的拥有者"),
    UserNotTargetBucketOwner(403, "UserNotTargetBucketOwner", "当前用户不是目标存储桶的拥有者"),
    InventoryConfigurationNotFoundError(404, "InventoryConfigurationNotFoundError", "清单配置未找到"),
    NoBucketQuotaPolicy(404, "NoBucketQuotaPolicy", "存储桶配额策略不存在"),
    NoSuchBucket(404, "NoSuchBucket", "指定的存储桶不存在"),
    NoSuchCopySource(404, "NoSuchCopySource", "复制对象源不存在"),
    NoSuchCORSConfiguration(404, "NoSuchCORSConfiguration", "指定的跨域资源共享配置不存在"),
    NoSuchEncryptionConfiguration(404, "NoSuchEncryptionConfiguration", "指定的存储桶加密配置不存在"),
    NoSuchJob(404, "NoSuchJob", "指定的批量处理任务不存在"),
    NoSuchKey(404, "NoSuchKey", "指定的对象键不存在"),
    NoSuchLifecycleConfiguration(404, "NoSuchLifecycleConfiguration", "指定的生命周期配置不存在"),
    NoSuchObjectLockConfiguration(404, "NoSuchObjectLockConfiguration", "指定的对象锁定配置不存在"),
    NoSuchPolicyVersion(404, "NoSuchPolicyVersion", "指定的策略版本不存在"),
    NoSuchTagSet(404, "NoSuchTagSet", "指定的标签集合不存在"),
    NoSuchUpload(404, "NoSuchUpload", "分块上传时指定的 UploadId 不存在"),
    NoSuchVersion(404, "NoSuchVersion", "指定版本不存在"),
    NoSuchWebsiteConfiguration(404, "NoSuchWebsiteConfiguration", "指定的静态网站配置不存在"),
    OriginConfigurationNotFoundError(404, "OriginConfigurationNotFoundError", "回源配置未找到"),
    ReplicationConfigurationNotFoundError(404, "ReplicationConfigurationNotFoundError", "跨地域复制配置未找到"),
    MethodNotAllowed(405, "MethodNotAllowed", "此资源不支持该 HTTP 方法"),
    RestoreNonArchiveObject(405, "RestoreNonArchiveObject", "不允许对非归档对象进行回热（恢复）"),
    UploadIdNotSupported(405, "UploadIdNotSupported", "指定的 UploadId 由 JSON API 生成，不能使用 XML API 操作"),
    AppendPositionErr(409, "AppendPositionErr", "Append 操作时，对象长度和 Position 不一致"),
    BucketAlreadyExists(409, "BucketAlreadyExists", "指定的存储桶已存在"),
    BucketAlreadyOwnedByYou(409, "BucketAlreadyOwnedByYou", "指定的存储桶已存在且由当前帐户创建"),
    BucketLocked(409, "BucketLocked", "存储桶已锁定，不能操作跨地域复制或生命周期"),
    BucketNotEmpty(409, "BucketNotEmpty", "存储桶不为空"),
    DomainConfigConflict(409, "DomainConfigConflict", "域名配置冲突，请删除冲突的记录"),
    InvalidBucketState(409, "InvalidBucketState", "存储桶状态与操作请求冲突，例如版本控制管理与跨地域复制的冲突"),
    InvalidLockedTime(409, "InvalidLockedTime", "对象锁定时间无效"),
    ObjectLocked(409, "ObjectLocked", "对象已锁定，不允许覆盖上传或删除该对象，也不允许通过复制修改该对象的元数据"),
    PathConflict(409, "PathConflict", "存在同名对象的毫秒级并发冲突"),
    QuotaConflict(409, "QuotaConflict", "配额冲突"),
    QuotaOperationConflict(409, "QuotaOperationConflict", "该存储桶的状态不适用于该操作"),
    RecordAlreadyExist(409, "RecordAlreadyExist", "DNS 记录冲突，请删除冲突的记录，或添加 CNAME/TXT 记录"),
    RestoreAlreadyInProgress(409, "RestoreAlreadyInProgress", "该对象正在回热（恢复）中"),
    UploadConflict(409, "UploadConflict", "同一个对象键频繁上传会导致冲突"),
    ObjectNotAppendable(409, "ObjectNotAppendable", "指定的对象不能追加"),
    MissingContentLength(411, "MissingContentLength", "Content-Length 请求头部缺失"),
    PreconditionFailed(412, "PreconditionFailed", "前置条件不匹配"),
    InvalidRange(416, "InvalidRange", "请求的对象范围不合法"),
    DomainAuditFailed(451, "DomainAuditFailed", "域名未备案"),
    UnavailableForLegalReasons(451, "UnavailableForLegalReasons", "当前服务不可用，请检查账号是否欠费，若无欠费请查看是否存在违规内容"),
    ;

    private Integer code;
    private String message;
    private String desc;

    TensentCosErrorEnum(Integer code, String message, String desc) {
        this.code = code;
        this.message = message;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static TensentCosErrorEnum getByMessage(String message) {
        if (StringUtils.isBlank(message)) {
            return null;
        }
        for (TensentCosErrorEnum tensentCosErrorEnum: TensentCosErrorEnum.values()) {
            if (tensentCosErrorEnum.getMessage().equals(message)) {
                return tensentCosErrorEnum;
            }
        }
        return null;
    }
}
